#!/usr/bin/env node
// 指定运行环境

console.log('我的脚手架')
const {
  Command
} = require('commander')
const terminal = require('terminal-kit')
const package = require('./package.json')

const program = new Command();

program.version(package.version)

program
  .command('init') // node index.js init
  .description('初始化项目')
  .action((options) => {
    console.log('command', options)
  })

program
  .option('-t, --transform <package name or path>', '插件路径或者npm包名称,支持多个插件，逗号分隔')
  .option('-o, --out <path>', '输出文件路径')
  .option('-s, --src <path>', '输入路径')
  .action((options) => {
    console.log('options', options)
  })

program
  .version(package.version)
  .description(terminal.terminal.blue(`版本号是${package.version}`))
  .action((version) => {
    console.log('version', version)
  })

program
  .option('-tt, --table')
  .action(() => {
    terminal.terminal.table([
      ['header #1', 'header #2', 'header #3'],
      ['row #1', 'a much bigger cell', 'cell']
    ], {})
  })

program
  .option('-int, --interaction')
  .action(() => {
    terminal.terminal('这个操作帅不帅？');

    terminal.terminal.singleColumnMenu([
      '是',
      '否'
    ], {
      style: terminal.terminal.bgGray.bold
    } , function (error, result) {
      if (result.selectedText === "是") {
        terminal.terminal.green("你选择了是");
        process.exit();
      } else {
        terminal.terminal.red("你选择了否");
        process.exit();
      }
    });
  })

program.parse(process.argv);